<?php

namespace App\Containers\AppSection\Project\Models;

use App\Containers\AppSection\Type\Models\Type;
use App\Ship\Parents\Models\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * Компания
 *
 * @property int $id Id
 * @property string $type_key Тип
 * @property array $participants Общее собрание: участники
 * @property string $body_name Наименование органа
 * @property string $participants_name Наименование участников
 * @property array $persons_information Сведения о лицах
 *
 * @property Type $type Тип
 */
class Government extends Model
{
    public $timestamps = false;
    protected $table = 'project_governments';
    protected $fillable = [
        'type_key',
        'participants',
        'body_name',
        'participants_name',
        'persons_information',
    ];

    protected $casts = [
        'participants' => 'json',
        'persons_information' => 'json',
    ];

    /**
     * A resource key to be used in the serialized responses.
     */
    protected string $resourceKey = 'Government';

    /**
     * Тип
     * @return BelongsTo Type
     */
    public function type(): BelongsTo
    {
        return $this->belongsTo(Type::class, 'type_key', 'key');
    }
}
